<template>
  <div id="accountListDay">
    <div v-if="isLoading">
      <group :title="item.day_time + '<span class=f26 style=float:right>总结余: '+ item.money_total +'元</span>'" v-for="(item, index) in accountData" :key="index">
        <cell :title="items.desc" :inline-desc='items.time_' v-for="(items, idx) in item.data_list" :key="idx">
          <p :class="[items.type== 1? 'text-orange': 'text-green']">{{ items.type == 1? '-': '+' }}{{ items.money }}</p>
        </cell>
      </group>
    </div>
    <load-more tip="加载数据中..." v-if="!isLoading"></load-more>
    <div class="null" v-if="isLoading && !accountData.length">
      该月暂无账单
    </div>
  </div>
</template>
<script>
import PubHeader from '../components/PubHeader.vue'
import { LoadMore, Cell, GroupTitle } from 'vux'
export default{
  components: {
    PubHeader,
    LoadMore,
    Cell,
    GroupTitle
  },
  created() {
    const date = new Date()
    const m = date.getMonth() + 1
    this.month = this.monthArr[this.$route.query.month || m]
    this.$http.post($config.host + '/api/Account/getUserBillEveryDay', qs.stringify({
      uid: this.$store.state.userInfo.uid,
      client: $config.client_type,
      device: $config.device_type,
      token: this.$store.state.userInfo.token,
      bill_year: this.$route.query.year || '',
      bill_month: this.$route.query.month || m
    })).then(res => {
      const {code, data, msg} = res.data
      this.isLoading = true
      if(code == '1' && data.data_list) {
        this.accountData = data.data_list
      } else {
        this.$vux.toast.text(msg, 'middle')
      }
    }).catch(err => {
      this.$vux.toast.text($config.errMsg, 'middle')
    })
  },
  data() {
    return {
      isLoading: false,
      accountData: [],
      month: '',
      monthArr: ['', '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
    }
  }
}
</script>
<style scoped>
  .weui-cells__title{
    margin-top: 0.47em !important;
  }
  .weui-cell{
    height: 1.15rem;
  }
</style>
